/**
 * 版本管理路由
 * 处理系统版本发布、更新策略和热修复等功能
 */

const express = require('express');
const router = express.Router();
const versionController = require('../controllers/version.controller');
const { authorize } = require('../middleware/permission.middleware');

/**
 * GET /admin/versions
 * 获取版本列表
 */
router.get('/', authorize(['superadmin', 'admin']), versionController.getVersions);

/**
 * POST /admin/versions
 * 创建新版本
 */
router.post('/', authorize(['superadmin']), versionController.createVersion);

/**
 * GET /admin/versions/:id
 * 获取版本详情
 */
router.get('/:id', authorize(['superadmin', 'admin']), versionController.getVersionDetail);

/**
 * PUT /admin/versions/:id
 * 更新版本信息
 */
router.put('/:id', authorize(['superadmin']), versionController.updateVersion);

/**
 * PUT /admin/versions/:id/release
 * 发布版本
 */
router.put('/:id/release', authorize(['superadmin']), versionController.releaseVersion);

/**
 * PUT /admin/versions/:id/rollback
 * 回滚版本
 */
router.put('/:id/rollback', authorize(['superadmin']), versionController.rollbackVersion);

/**
 * GET /admin/versions/:id/changelog
 * 获取版本更新日志
 */
router.get('/:id/changelog', authorize(['superadmin', 'admin']), versionController.getChangelog);

/**
 * GET /admin/versions/strategy
 * 获取更新策略配置
 */
router.get('/strategy', authorize(['superadmin', 'admin']), versionController.getUpdateStrategy);

/**
 * PUT /admin/versions/strategy
 * 更新更新策略配置
 */
router.put('/strategy', authorize(['superadmin']), versionController.updateUpdateStrategy);

module.exports = router;